﻿@using Abp.Application.Editions
@using Abp.Application.Services.Dto
@using Abp.Extensions
@using AbpZeroTemplate.Web.Areas.AppAreaName.Models.Common.Modals
@using AbpZeroTemplate.Web.Areas.AppAreaName.Models.Editions
@model CreateOrEditEditionModalViewModel

@Html.Partial("~/Areas/AppAreaName/Views/Common/Modals/_ModalHeader.cshtml", new ModalHeaderViewModel(Model.IsEditMode ? (L("EditEdition") + ": " + Model.Edition.DisplayName) : L("CreateNewEdition")))

<div class="modal-body">

    <ul class="nav nav-tabs  m-tabs-line" role="tablist">
        <li class="nav-item m-tabs__item">
            <a href="#EditionInformationsTab" class="nav-link m-tabs__link active" data-toggle="tab" role="tab">
                @L("EditionProperties")
            </a>
        </li>
        <li class="nav-item m-tabs__item">
            <a href="#FeaturesTab" class="nav-link m-tabs__link" data-toggle="tab" role="tab">
                @L("Features")
            </a>
        </li>
    </ul>

    <div class="tab-content">
        <div class="tab-pane active" id="EditionInformationsTab" role="tabpanel">

            <form name="EditionInformationsForm" role="form" novalidate class="form-validation">

                @if (Model.IsEditMode)
                {
                    <input type="hidden" name="Id" value="@Model.Edition.Id" />
                }

                <div class="form-group ">
                    <label for="DisplayName">@L("EditionName")</label>
                    <input class="form-control@(Model.Edition.DisplayName.IsNullOrEmpty() ? "" : " edited")"
                           type="text"
                           name="DisplayName"
                           id="DisplayName"
                           value="@Model.Edition.DisplayName"
                           required
                           maxlength="@Edition.MaxDisplayNameLength">
                </div>

                <label>@L("SubscriptionPrice")</label>
                <div class="m-radio-inline">
                    <label for="EditEdition_IsFree" class="m-radio">
                        <input id="EditEdition_IsFree" name="SubscriptionPrice" @(!Model.Edition.MonthlyPrice.HasValue && !Model.Edition.AnnualPrice.HasValue ? "checked=\"checked\"" : "") type="radio">
                        @L("Free")
                        <span></span>
                    </label>
                    <label for="EditEdition_IsPaid" class="m-radio">
                        <input id="EditEdition_IsPaid" name="SubscriptionPrice" @(Model.Edition.MonthlyPrice.HasValue || Model.Edition.AnnualPrice.HasValue ? "checked=\"checked\"" : "") type="radio">
                        @L("Paid")
                        <span></span>
                    </label>
                </div>

                <div class="paid-features">
                    <div class="row SubscriptionPrice">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="MonthlyPrice">@L("MonthlyPrice")</label>
                                <input name="MonthlyPrice"
                                       id="MonthlyPrice"
                                       type="text"
                                       class="form-control@(!Model.Edition.MonthlyPrice.HasValue ? "" : " edited")"
                                       value="@(Model.Edition.MonthlyPrice?.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture))" />
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="AnnualPrice">@L("AnnualPrice")</label>
                                <input name="AnnualPrice"
                                       id="AnnualPrice"
                                       type="text"
                                       class="form-control@(!Model.Edition.AnnualPrice.HasValue ? "" : " edited")"
                                       value="@Model.Edition.AnnualPrice?.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)" />
                            </div>
                        </div>
                    </div>

                    <div class="m-checkbox-list">
                        <label for="EditEdition_IsTrialActive" class="m-checkbox">
                            <input id="EditEdition_IsTrialActive" class="md-check" type="checkbox" name="IsTrialActive" value="true" @(Model.Edition.TrialDayCount.HasValue ? "checked=\"checked\"" : "") />
                            @L("IsTrialActive")
                            <span></span>
                        </label>
                    </div>

                    <div class="form-group trial-day-count">
                        <label for="TrialDayCount">@L("TrialDayCount")</label>
                        <input class="form-control@(!Model.Edition.TrialDayCount.HasValue ? "" : " edited")"
                               type="number" 
                               name="TrialDayCount"
                               id="TrialDayCount"
                               value="@Model.Edition.TrialDayCount">
                    </div>

                    <div class="m-checkbox-list">
                        <label for="EditEdition_IsWaitingDayActive" class="m-checkbox">
                            <input id="EditEdition_IsWaitingDayActive" type="checkbox" name="IsWaitingDayActive" value="true" @(Model.Edition.WaitingDayAfterExpire.HasValue ? "checked=\"checked\"" : "") />
                            @L("WaitAfterSubscriptionExpireDate")
                            <span></span>
                        </label>
                    </div>

                    <div class="form-group waiting-day-after-expire">
                        <label for="WaitingDayAfterExpire">@L("WaitingDayAfterExpire")</label>
                        <input class="form-control@(!Model.Edition.WaitingDayAfterExpire.HasValue ? "" : " edited")"
                               type="number" 
                               name="WaitingDayAfterExpire"
                               id="WaitingDayAfterExpire"
                               value="@Model.Edition.WaitingDayAfterExpire">
                    </div>

                    <label>@L("WhatWillDoneAfterSubscriptionExpiry")</label>
                    <div class="m-radio-inline">
                        <label for="EditEdition_ExpireAction_DeactiveUser" class="m-radio">
                            <input id="EditEdition_ExpireAction_DeactiveUser" name="ExpireAction" @(!Model.Edition.ExpiringEditionId.HasValue ? "checked=\"checked\"" : "") type="radio">
                            @L("DeactiveTenant")
                            <span></span>
                        </label>
                        <label for="EditEdition_ExpireAction_AssignEdition" class="m-radio">
                            <input id="EditEdition_ExpireAction_AssignEdition" name="ExpireAction" class="md-radiobtn" @(Model.Edition.ExpiringEditionId.HasValue ? "checked=\"checked\"" : "") type="radio">
                            @L("AssignToAnotherEdition")
                            <span></span>
                        </label>
                    </div>

                    <div class="form-group edition-list">
                        @Html.DropDownList("ExpiringEditionId", Model.FreeEditionItems.Select(i => i.ToSelectListItem()), new { @class = "form-control" + (Model.Edition.DisplayName.IsNullOrEmpty() ? "" : " edited") })
                    </div>
                </div>
            </form>

        </div>
        <div class="tab-pane" id="FeaturesTab" role="tabpanel">
            @Html.Partial("~/Areas/AppAreaName/Views/Common/_FeaturesTree.cshtml", Model)
        </div>
    </div>
</div>

@Html.Partial("~/Areas/AppAreaName/Views/Common/Modals/_ModalFooterWithSaveAndCancel.cshtml")